package com.bci.internal.engine.bcibpmengine.validator;


import com.bci.internal.engine.bcibpmengine.utils.BCValidationUtils;
import com.bci.internal.engine.bcibpmengine.validator.annotation.ChineseAlphabetDigit;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 中英文数字验证器
 *  @author jzwu
 * @since 2021/4/4 0004
 */
public class ChineseAlphabetDigitValidator implements ConstraintValidator<ChineseAlphabetDigit, String> {

    @Override
    public boolean isValid(String text, ConstraintValidatorContext ctx) {
        if (text == null || text.isEmpty()) {
            return true;
        }
        return BCValidationUtils.isChineseOrAlphabetOrDigit(text);
    }
}